#include "Logic/MBCustomInstancedBatchProxy.h"


FMBCustomInstancedBatchProxy::FMBCustomInstancedBatchProxy(UActorComponent* Owner):
	FMBInstancedBatchProxyAbstract()
{
	CustomFloatNum = 0;
	bHidden = true;
	OwnerComponent = Owner;
}

void FMBCustomInstancedBatchProxy::ApplyCustomData(TArray<float>& PerInstanceSMCustomData)
{
	for(const FMBCustomInstanceBatchCharacterRenderInfo& UnitInfo : UnitInfoArray)
	{
		switch (CustomFloatNum)
		{
		case  0:break;
		case 1:
			PerInstanceSMCustomData.Add(UnitInfo.CustomData1);
			break;
		case 2:
			PerInstanceSMCustomData.Add(UnitInfo.CustomData1);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData2);
			break;
		case 3:
			PerInstanceSMCustomData.Add(UnitInfo.CustomData1);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData2);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData3);
			break;
		case 4:
			PerInstanceSMCustomData.Add(UnitInfo.CustomData1);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData2);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData3);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData4);
			break;
		case 5:
			PerInstanceSMCustomData.Add(UnitInfo.CustomData1);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData2);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData3);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData4);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData5);
			break;
		case 6:
			PerInstanceSMCustomData.Add(UnitInfo.CustomData1);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData2);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData3);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData4);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData5);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData6);
			break;
		case 7:
			PerInstanceSMCustomData.Add(UnitInfo.CustomData1);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData2);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData3);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData4);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData5);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData6);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData7);
			break;
		case 8:
			PerInstanceSMCustomData.Add(UnitInfo.CustomData1);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData2);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData3);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData4);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData5);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData6);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData7);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData8);
			break;
		case 9:
			PerInstanceSMCustomData.Add(UnitInfo.CustomData1);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData2);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData3);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData4);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData5);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData6);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData7);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData8);
			PerInstanceSMCustomData.Add(UnitInfo.CustomData9);
			break;
			default: check(0);
		}
	}
}

void FMBCustomInstancedBatchProxy::ApplyTransform(TArray<FTransform>& PerInstanceSMData)
{
	for(const FMBCustomInstanceBatchCharacterRenderInfo& UnitInfo : UnitInfoArray)
	{
		PerInstanceSMData.Add(UnitInfo.Transform);
	}
}

int FMBCustomInstancedBatchProxy::NumCustomDataFloats()
{
	return CustomFloatNum;
}